<?php
/**
 * 肤质检测仪常量
 *
 * @author Zeon <scplay@gmail.com>
 * @date 2018/6/7
 * @copyright PanxSoft Inc.
 */
namespace App\Models\Panx;

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;

/**
 * @property int id
 *
 * @method static self filterDeleted(int $is_deleted = 1)
 */
class SkinDetector extends Model
{
    const SKIN_DETECTOR_NO = 0;  // 肤质检测仪的检测类型 0：无。
    /** @deprecated - SKIN_DETECTOR_CAMERA - App已取消拍照检测 */
    const ID_CAMERA = 1;  // 肤质检测仪的检测类型 2：摄像头拍摄检测。
    const ID_WAX = 2;  // 肤质检测仪的检测类型 1：唯丝普接触图像检测仪。
    const ID_HM = 3; // 肤质检测仪的检测类型 3：汇美接触式检测仪

    const NOT_DELETED = 0;
    const IS_DELETED = 1;

    protected $table = 'skin_detectors';

    protected $guarded = [];

    /**
     * 可用的肤质检测仪 ID
     *
     * @return array
     */
    public static function validatedIds(): array
    {
        return [
            self::ID_WAX,
            self::ID_HM,
        ];
    }

    /**
     * @used-by filterDeleted
     * @param Builder $builder
     * @param int $is_del
     *
     * @return Builder
     */
    public function scopeFilterDeleted(Builder $builder, int $is_del = self::IS_DELETED)
    {
        return $builder->where('is_deleted', $is_del);
    }
}
